package com.huawei.hwclouds.lubanops.demo.common.client;

import java.util.Map;

/**
 * http调用返回的结果，包含状态码和结果内容 <br>
 *
 * @author y00438022
 * @since 2020年3月2日
 */
public class HttpCallResult {
    private int status;

    private String content;

    private Map<String, String> headers;

    public HttpCallResult(int status, String content, Map<String, String> headers) {
        this.status = status;
        this.content = content;
        this.headers = headers;
    }

    public Map<String, String> getHeaders() {
        return headers;
    }

    /**
     * 根据key获取header里面的值
     *
     * @param key
     * @return
     */
    public String getHeaderValue(String key) {
        if (headers == null || headers.isEmpty()) {
            return null;
        }
        return headers.get(key);
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @Override
    public String toString() {
        return "[" + status + "][" + content + "]";
    }
}
